<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>

  <body>
    <!-- 
		使用具名插槽：
			1.slot添加name：给模板中的slot添加name属性名与自定义值
			2.使用指定slot：在组件实例内添加元素并且写入slot属性名与值，就能根据属性值绑定具有同样值的slot插槽
	 -->
    <div id="app">
      <cpn><span slot="center">标题</span></cpn>

      <cpn><button slot="left">标题</button></cpn>
    </div>

    <template id="cpn">
      <div>
        <slot name="left">左</slot>
        <slot name="center">中</slot>
        <slot name="right">右</slot>
      </div>
    </template>

    <script src="../js/vue.js"></script>
    <script>
      const app = new Vue({
        el: '#app',
        data: {
          message: '你好'
        },
        components: {
          cpn: {
            template: '#cpn'
          }
        }
      })
    </script>
  </body>
</html>
